#include "pacman.h"

Pacman::Pacman(int x,int y,int w,int h,QString pic):
    x(x)
  ,y(y)
  ,width(w)
  ,height(h)
  ,pic(pic)
  ,direction(Direction::RIGHT)
  ,originX(x)
  ,originY(y)
{

}


void Pacman::draw(QPainter& p){

    p.drawPixmap(x,y,width,height,pic);
}

void Pacman::setPos(int x,int y){
    this->x = x;
    this->y = y;
}

int &Pacman::rx(){
    return x;
}

int &Pacman::ry(){
    return y;
}

int &Pacman::rOriginX(){
    return originX;
}

int &Pacman::rOriginY(){
    return originY;
}


void Pacman::setFace(const Direction &d,QPixmap pic){
    faces[d] = pic;
}

void Pacman::setDirection(const Direction &d,int distance){
    this->pic = faces[d];
    switch (d) {
    case Direction::UP:
        y -= distance;
        break;
    case Direction::DOWN:
        y+=distance;
        break;
    case Direction::LEFT:
        x -= distance;
        break;
    case Direction::RIGHT:
        x += distance;
        break;
    default:
        break;
    }
}


QHash<Direction,QPixmap> &Pacman::face(){
    return faces;
}

uint qHash(const Direction &d,uint seed){
    return static_cast<int>(d) + seed;
}



Enemy::Enemy(int x,int y,int w,int h,QString pic)
    :Pacman(x,y,w,h,pic)
{

}

Food::Food(int x,int y,int w,int h,QString pic)
    :Pacman(x,y,w,h,pic)
{

}


